#ifndef HB_STEREOAPI_H
#define HB_STEREOAPI_H

#include <stdio.h>
#include <vector>
#include <opencv2/calib3d/calib3d.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/videoio/videoio.hpp>


/*
**
**		leftGray: 				stereo left gray image
** 		rightGray: 				stereo right grey image
** 		cameraMatrixLeft: 		stereo left intrinsics parameters
** 		cameraMatrixRight: 		stereo right intrinsics parameters
**		discoeffLeft: 			left camera distortion coefficient
** 		discoeffRight: 			right camera distortion coefficient
**		R: 							the rotation of the right camera to the lift camera
** 		T: 							the translation of the right camera to the lift camera
** 		rectifyImageL: 			return correct left image
** 		rectifyImageR: 			return correct right image
**
*/
void correctStereoImages(const cv::Mat &leftGray, const cv::Mat &rightGray,
			cv::Mat &cameraMatrixLeft, cv::Mat &cameraMatrixRight, cv::Mat &discoeffLeft, cv::Mat &discoeffRight, cv::Mat &R, cv::Mat &T,
			cv::Mat &rectifyImageL, cv::Mat &rectifyImageR, cv::Rect &validRoil, cv::Rect &validRoir, cv::Mat &q);

/*
**
**		validRoil:				stereoRectify validPixROI1 
**		validRoir:				stereoRectify validPixROI2 
**		rectifyImageL: 			correct left image
**		rectifyImageR:			correct right image
**		leftDisp:					return depth map
**
*/
void stereoMatch(cv::Rect &validRoil, cv::Rect &validRoir, cv::Mat &rectifyImageL, cv::Mat &rectifyImageR, cv::Mat &leftDisp);



/*
**
**		leftGray: 			stereo left gray image
** 		rightGray: 			stereo right grey image
** 		cameraMatrixLeft: 	stereo left intrinsics parameters
** 		cameraMatrixRight: 	stereo right intrinsics parameters
**		discoeffLeft: 		left camera distortion coefficient
** 		discoeffRight: 		right camera distortion coefficient
**		R: 						the rotation of the right camera to the lift camera
** 		T: 						the translation of the right camera to the lift camera
** 		depthMap: 			return left depth map iamge
**
*/
void stereoCalculateDepthMap(const cv::Mat &leftGray, const cv::Mat &rightGray,
			cv::Mat &cameraMatrixLeft, cv::Mat &cameraMatrixRight, cv::Mat &discoeffLeft, cv::Mat &discoeffRight, cv::Mat &R, cv::Mat &T, cv::Mat &depthMap, cv::Mat &xyz);



#endif  //HB_STEREOAPI_H
